var should = require('should');
var async = require('async');
var dailyTaskHandler = require('../../../app/servers/user/handler/dailyTaskHandler');
var config = require('../../config');
var PlayerManager = require('../../../app/libs/playerManager');
var configUtil = require('../../../app/util/configUtil');
var analyze = require('kc-analyze');
var _ = require('lodash');
var checkModel = require('../../../app/models/checkModel');

suite('测试dailyTaskHandler', function () {
    var player_manager = new PlayerManager(config.role_id);
    setup(function (done) {
        async.waterfall(
            [
                function (cb) {
                    player_manager.getAllModel(cb);
                },
                function (cb) {
                    player_manager.daily_task.complete_task_list = [];
                    player_manager.daily_task.static_list = {
                        7: {
                            battle_win_num: 10
                        }
                    };
                    player_manager.daily_task.addTask(30001);
                    cb();
                },
                function (cb) {
                    player_manager.save(cb);
                }
            ],
            function (err) {
                done();
            }
        );
    });

    setup(function (done) {
        var analyze_config = configUtil.load('analyze');
        var game_config = configUtil.load('game');
        analyze.initialize({
            host: analyze_config.host,
            server_id: game_config.server_id
        });
    });

    suite('reward', function () {
        test('获取任务奖励', function (done) {
            var msg = {};
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.reward(msg, session, function (err, res) {
                done();
            });
        });

        test('获取任务奖励', function (done) {
            var msg = {
                daily_task_id: 30001
            };
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.reward(msg, session, function (err, res) {
                done();
            });
        });
    });
});

suite('测试receiveDailyActive', function () {
    suite('receiveDailyActive', function () {
        test('获取任务奖励', function (done) {
            var msg = {};
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.receiveDailyActive(msg, session, function (err, res) {
                done();
            });
        });

        test('获取任务奖励', function (done) {
            var msg = {
                active_id: 70
            };
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.receiveDailyActive(msg, session, function (err, res) {
                done();
            });
        });
    });
});

suite('receiveEnergy', function () {
    suite('receiveEnergy', function () {
        test('领取每日时间点体力任务奖励接口', function (done) {
            var msg = {};
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.receiveEnergy(msg, session, function (err, res) {
                done();
            });
        });

        test('领取每日时间点体力任务奖励接口', function (done) {
            var msg = {
                daily_task_id: 30003
            };
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.receiveEnergy(msg, session, function (err, res) {
                done();
            });
        });
    });
});

suite('测试receiveMonthDay', function () {
    suite('receiveMonthDay', function () {
        test('获取月卡任务奖励', function (done) {
            var msg = {};
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.receiveMonthDay(msg, session, function (err, res) {
                done();
            });
        });

        test('获取月卡任务奖励', function (done) {
            var msg = {
                daily_task_id: 30014
            };
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.receiveMonthDay(msg, session, function (err, res) {
                done();
            });
        });
    });
});

suite('测试receiveExtreme', function () {
    suite('receiveExtreme', function () {
        test('领取每日至尊卡送钻石接口', function (done) {
            var msg = {};
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.receiveExtreme(msg, session, function (err, res) {
                done();
            });
        });

        test('领取每日至尊卡送钻石接口', function (done) {
            var msg = {
                daily_task_id: 30020
            };
            var session = {};
            session.uid = config.role_id;

            var dailyTask_Handler = new dailyTaskHandler();
            dailyTask_Handler.receiveExtreme(msg, session, function (err, res) {
                // console.log('res:', res);
                done();
            });
        });
    });
});
